#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    vector<vector<int>> transpose(vector<vector<int>>& A) 
    {
        int x = A.size();
        int y = A[0].size();
        vector<vector<int>> v(y,vector<int>(x));
        for (int i = 0; i < A.size(); i++)
        {
            for(int j = 0; j < A[0].size(); j++)
            {
                v[j][i] = A[i][j];
            }
        }
    	return v;
    }
};

void printVector(vector<vector<int>> & v)
{

	for (int i = 0; i < v.size(); i++)
	{
		for(int j = 0; j < v[0].size(); j++)
		{
			cout << v[i][j] << '\t';
		}
		cout << endl;
	}
	cout << endl;
}

void printVector1(vector<vector<int>> & v)
{
    if (v.empty())
    {
        cout << "empty";
        return;
    }
    else
    {
        for (int i = 0; i < v[0].size(); i++)
        {
            for(int j = 0; j < v.size(); j++)
            {
                cout << v[j][i] << '\t';
            }
            cout << endl;
        }
    }
    cout << endl;
}

int main()
{
    vector<vector<int>> v1=
    {
        {1,2,3},
        {4,5,6},
        {7,8,9}
    };
    vector<vector<int>> v2=
    {
    	{1,2,3},
    	{4,5,6},
    };
    Solution s;
    vector<vector<int>> v3 = s.transpose(v1);
    printVector(v1);
    printVector(v3);
    return 0;
}

